﻿$("#Main").datagrid({
    url: "/Admin/ArticleCategory/GetList?useLevel=1",
    fit: true,
    fitColumns: true,
    striped: true,
    rownumbers: true,
    remoteSort: false,
    singleSelect: true,
    idField: "ID",
    toolbar: [{
        text: '添加新类型',
        iconCls: 'icon-add',
        handler: function () { add(); }
    }],
    columns: [[{
        title: "分类名称",
        field: "CatName",
        width: 15
    }, {
        title: "别名",
        field: "UniqueID",
        width: 15
    }, {
        title: "简单描述",
        field: "Description",
        width: 48
    }, {
        title: "排序",
        field: "Sort",
        width: 10
    }, {
        field: 'action',
        title: '编辑',
        width: 12,
        align: 'center',
        formatter: function (value, row, index) {
            return '<a href="#" onclick="edit(' + row.ID + ')">编辑</a>&nbsp;|&nbsp;<a href="#" onclick="del(' + row.ID + ')">删除</a>';
        }
    }]]
});
function add() {
    location.href = "/Admin/ArticleCategory/Create?current=6&r=" + Math.random();
}
function edit(id) {
    location.href = "/Admin/ArticleCategory/Edit/" + id + "?current=6&r=" + Math.random();
}
function del(id) {
    $.messager.confirm('警告', '确定删除?', function (r) {
        if (r)
            location.href = "/Admin/ArticleCategory/Delete/" + id + "?current=6&r=" + Math.random();
    });
}